import {createConnection} from 'typeorm';

export const databaseProviders = [
    {
        provide: 'MongoBookConnectionToken',
        useFactory: async () =>
            await createConnection({
                type: 'mongodb',
                host: process.env.mongo_host,
                port: parseInt(process.env.mongo_port),
                database: 'book',
                entities: [__dirname + '/**/mongo/book/*.entity{.ts,.js}'],
            }),
    },
    {
        provide: 'MongoTaoConnectionToken',
        useFactory: async () =>
            await createConnection({
                type: 'mongodb',
                host: process.env.mongo_host,
                port: parseInt(process.env.mongo_port),
                database: 'tao',
                entities: [__dirname + '/**/mongo/tao/*.entity{.ts,.js}'],
            }),
    },
];